package com.spring.boot.configer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * springboot 启动就执行
 * 实现 ApplicationRunner 接口，重新Run方法
 */
@Component
public class StartConfig implements ApplicationRunner {

    @Autowired
    StringRedisTemplate redisTemplate;


    @Override
    public void run(ApplicationArguments args) throws Exception {

        //字符串
        redisTemplate.opsForValue().set("name","tony");
        System.out.println(redisTemplate.opsForValue().get("name"));
        redisTemplate.boundValueOps("name").set("mike");
        System.out.println(redisTemplate.boundValueOps("name").get());


//        System.out.println("aaaaaaaaaaaaaa");

    }
}
